<!DOCTYPE html>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8"/>
<meta name="viewport" id="viewport" content="width=device-width,initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no">
<meta name="format-detection" content="telephone=no"/>
<title>订单详细</title>
<link href="/static/webAPP/css/reset.css" rel="stylesheet" type="text/css">
<link href="/static/webAPP/css/indent-details.css" rel="stylesheet" type="text/css">
</head>
<body>
<div class="near-box">
    <a href="javascript:history.go(-1);" class="jd-qrdd-topbox">订单详情</a>
    <div class="jd-qrdd-bigbox">
        <!--商品地址管理部分-->
        <div class="indent-details-box">
            <span class="indent-details-img1"></span>
            <span class="indent-details-text1 order_status">已发货</span>
            <span class="indent-details-text2">取货地点：<i class="order_place"></i></span>
            <span class="indent-details-text3">取货码:<i class="num_pickups" style="color: #FF9201;font-size: large;"></i></span>
        </div>
        <!--商品部分-->
        <div class="zjzz-buylist-goods1">
            
        </div>
        <!--商品金额部分-->
        <div class="indent-details-box2">
            <span class="indent-details-text4">总金额</span>
            <span class="indent-details-text5">￥<i class="order_amount"></i></span>
        </div>
        
        <!--订单编号部分-->
        <div class="indent-details-box3">
            <p>订单编号:<i class="order_number"></i></p>
            <!-- <p>支付方式:<i class="order_paymothod"></i></p> -->
            <p>订单时间:<i class="order_time"></i></p>
            <p>备注:<i class="order_remarks"></i></p>
        </div>
    </div>
</div>

<script src="/static/webAPP/js/jquery-1.8.3.min.js"></script>
<script>
$(function(){
    var oid = getUrlParam('id')
    var user_id = getUrlParam('userid')
    $.ajax({
        type: "post",
							//TODO:
        url: "/app/bookOrder/getOrderDetail",
        data: {order_id: oid,user_id: user_id},
        dataType: "json",
        success: function(mag){
            if (mag.success == true) {
                $(".order_status").html(isStatus(mag.data.order_status))
                $(".order_place").html(mag.data.machine.place)
                $(".order_number").html(mag.data.id)
                // $(".order_paymothod").html(mag.data.pay_method)
                $(".order_time").html(timestampToTime(mag.data.create_date))
                $(".order_remarks").html(mag.data.comment)
                $(".order_amount").html(mag.data.amount)
                $(".num_pickups").html(mag.data.pick_code)
                var tag = ''
                for (let i = 0; i < mag.data.commodities.length; i++) {
                    var tag1 = '<div class="zjzz-buylist-det"><div class="zjzz-buylist-gdetail"><span class="zjzz-buylist-gtit1">'+ mag.data.commodities[i].commodityName +'</span><span class="zjzz-buylist-gmoney"><i class="zjzz-buylist-gm1">￥'+ mag.data.commodities[i].price +'</i><i class="zjzz-buylist-gm2">'+ mag.data.commodities[i].specifications +'</i><i class="zjzz-buylist-gm2">x'+ mag.data.commodities[i].count +'</i></span></div></div>'
                    tag += tag1
                }
                $(".zjzz-buylist-goods1").html(tag)
            }
        }
    })
})

    //获取后台传参
function getUrlParam(name) {
    var reg = new RegExp("(^|&)"+ name +"=([^&]*)(&|$)");
	var r = window.location.search.substr(1).match(reg);
    if (r != null) return unescape(r[2]);
    return null;
 }

 function timestampToTime(timestamp) {
    var date = new Date(timestamp * 1);//时间戳为10位需*1000，时间戳为13位的话不需乘1000
    Y = date.getFullYear() + '-';
    M = (date.getMonth()+1 < 10 ? '0'+(date.getMonth()+1) : date.getMonth()+1) + '-';
    D = (date.getDate() < 10 ? '0'+date.getDate() : date.getDate()) + ' ';
    h = (date.getHours() < 10 ? '0' +date.getHours() : date.getHours()) + ':';
    m = (date.getMinutes() < 10 ? '0' +date.getMinutes() : date.getMinutes()) + ':';
    s = (date.getSeconds() < 10 ? '0' +date.getSeconds() : date.getSeconds());
    return Y+M+D+h+m+s;
 }
function isStatus(num) {
    if (num == 0) {
        return '待付款'
    }else if (num == 1) {
        return '待发货'
    }else if (num == 2) {
        return '待收货'
    // }else if (num == 3) {
    //     return '待评价'
    }else if (num == 6) {
        return '订单取消'
    }else if (num == 8) {
        return '退款订单'
    }else{
        return '已完成'
    }
}
</script>
</body>

</html>